#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;

struct node{
    int d, v;
    long double a;
}car[N];
long double p[N];
int chafen[N];
int T;
int n, m, l, ans;
long double vmax;
int cnt;

void f(){
    vector<int> cc;
    for(int i = 1; i <= n; i++)
        if(car[i].v > vmax){
            int tmp = lower_bound(p + 1, p + 1 + m, car[i].d) - p;
            if(tmp >= 1 && tmp <= m && p[tmp] >= car[i].d){
                cnt ++; 
            }
        }
    if(cnt == 0) ans = m;
    else ans = max(0, m - 1);
    cout << cnt << " " << ans << endl;
}

void work(){
    // int last = 0;
    // bool vis[N];
    // int b = INT_MAX;
    for(int i = 1; i <= n; i++){
        long double chaosu;
        if(car[i].a == 0){
            if(car[i].v > vmax){
                int tmp = lower_bound(p + 1, p + 1 + m, car[i].d) - p;
                if(tmp >= 1 && tmp <= m && p[tmp] >= car[i].d){
                    cnt ++; 
                    // last = max(last, i);
                }
            }
            continue;
        }
        else if(car[i].v > vmax){
            int tmp = lower_bound(p + 1, p + 1 + m, car[i].d) - p;
            if(tmp >= 1 && tmp <= m && p[tmp] >= car[i].d){
                int vv = car[i].v * car[i].v + 2 * car[i].a * (p[tmp] - car[i].d);
                if(vv < 0) continue;
                vv = sqrt(vv);
                if(vv > vmax){
                    cnt ++;    

                }
                
            }
            continue;
        }
        else{

            chaosu = vmax * vmax - car[i].v * car[i].v;
            chaosu = chaosu / (2.0 * car[i].a);
            // cout << chaosu << endl;
            chaosu += car[i].d;
        }
        
        // if(chaosu < 0 || chaosu > l) continue;
        int tp = int(chaosu) + 1;
        int tmp = lower_bound(p + 1, p + 1 + m, tp) - p;

        // cout  << i << " " << chaosu << " " << tmp << " " << p[tmp] << endl;
        if(tmp >= 1 && tmp <= m){
            if(p[tmp] >= tp)
                cnt ++;
        }
    }
    if(cnt == 0) ans = m;
    else ans = m - 1;
    return ;
}

int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> T;
    while(T --){
        cnt = 0;
        bool flag = 1;
        cin >> n >> m >> l >> vmax;
        for(int i = 1; i <= n; i++){
            cin >> car[i].d >> car[i].v >> car[i].a;
            if(car[i].a != 0)
                flag = 0;
        }
        for(int i = 1; i <= m; i++){
            cin >> p[i];
        }
        if(flag){
            f();
            continue;
        }
        else{
            work();
        }

        cout << cnt << " " << ans << endl;
    } 
    return 0;
}